"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const fs = __importStar(require("fs"));
const path_1 = __importDefault(require("path"));
const vue_1 = require("vue");
const lib_css_1 = __importDefault(require("../../../../../../@libs/nodejs-lib-main/lib_css"));
const global_1 = require("../../../../config/global");
const conv_role_dialog_1 = __importDefault(require("../PropertyCompoents/conv_role_dialog/conv_role_dialog"));
const location_dialog_1 = __importDefault(require("../PropertyCompoents/location_dialog/location_dialog"));
const component = {
    components: { ConvRoleDialog: conv_role_dialog_1.default, LocDialog: location_dialog_1.default },
    template: fs.readFileSync(`${__dirname}/conFlow_property.html`, "utf-8"),
    name: '',
    props: {
        treeData: "",
        nodeData: Object,
        lf: Object || String,
    },
    mounted() {
        lib_css_1.default.load([
            {
                parent: this.$el,
                url_s: path_1.default.join(`${__dirname}/conFlow_property.css`),
            },
        ]);
        const { properties, text } = this.$props.nodeData;
        if (properties) {
            this.$data.formData = Object.assign({}, this.$data.formData, properties);
            if (this.$data.formData.rolePos == 'true') {
                this.$data.formData.rolePos = true;
            }
            else {
                this.$data.formData.rolePos = false;
            }
            console.log("newDialogue.rolePos类型", typeof this.$data.formData.rolePos);
        }
        if (text && text.value) {
            this.$data.formData.graphRes_title = text.value;
        }
        if (text && text.value) {
            this.$data.text = text.value;
        }
    },
    methods: {
        onSubmit() {
            const { properties, id } = this.$props.nodeData;
            let newDialogue = this.$data.formData;
            this.$props.lf.setProperties(id, Object.assign({}, newDialogue));
            this.$props.lf.updateText(id, this.$data.formData.graphRes_title);
        },
        openRole(id) {
            console.log("id", id);
            this.$data.selectID = id;
            this.$data.role_visible = true;
        },
        //确认角色图片
        sureConvRolePic(selectRole) {
            this.$data.currentRole = selectRole;
            this.$data.formData.currentConvFlow = new global_1.convFlow(selectRole.role_name, selectRole.role_id, selectRole.role_pic, -1, '');
            this.$data.formData.convFlowList[this.$data.selectID].role_name = selectRole.role_name;
            this.$data.formData.convFlowList[this.$data.selectID].role_id = selectRole.role_id;
            this.$data.formData.convFlowList[this.$data.selectID].role_pic = selectRole.role_picUrl;
            this.$data.role_visible = false;
            this.$data.isSelect = false;
        },
        closeRolePanel() {
            this.$data.role_visible = false;
            this.$data.formData = {
                graphRes_title: '',
                graphRes_id: '',
                rolePos: (0, vue_1.ref)(false),
                locationName: '',
                locationID: '',
                convFlowList: [] //对话流
            };
        },
        sureLocPic(selectLocation) {
            this.$data.currentLoc = selectLocation;
            this.$data.formData.locationPic = selectLocation.location_picUrl;
            this.$data.formData.locationName = selectLocation.location_name;
            this.$data.formData.locationID = selectLocation.location_id;
            this.$data.loc_visible = false;
            this.$data.isSelect = false;
        },
        closeLocPanel() {
            this.$data.loc_visible = false;
        },
        handleChange(val) {
            console.log("打开折叠面板", val);
        },
        generateName(index) {
            // 生成递增的name属性
            console.log("生成递增的name属性", name);
            return index.toString();
        },
    },
    data() {
        return {
            selectID: 0,
            mouse: {
                left: 0,
                top: 0
            },
            loc_visible: (0, vue_1.ref)(false),
            role_visible: (0, vue_1.ref)(false),
            text: '',
            formData: {
                currentConvFlow: global_1.convFlow,
                graphRes_title: '',
                graphRes_id: '',
                rolePos: (0, vue_1.ref)(true),
                locationName: '',
                locationID: '',
                convFlowList: [] //对话流
            }
        };
    },
    watch: {},
    created() { },
};
module.exports = component;
